using System.IO;

namespace SolutionFactory.Services
{
    public class UncheckReadonlyVisitor : IFileVisitor
    {
        private readonly ILogger _logger;

        public UncheckReadonlyVisitor(ILogger logger)
        {
            _logger = logger;
        }

        public void Visit(FileInfo file)
        {
            if(file.IsReadOnly)
            {
                _logger.Log(string.Format("{0} is readonly, unchecking the readonly flag...", file.FullName));
                file.IsReadOnly = false;
            }
                
        }
    }
}